class PositionsController < ApplicationController
  def index
    @positions = Position.paginate :page => params[:page], :order => 'id'

    respond_to do |format|
      format.html 
      format.xml  { render :xml => @positions }
    end
  end

  def show
    @position = Position.find(params[:id])

    respond_to do |format|
      format.html 
      format.xml  { render :xml => @position }
    end
  end

  def new
    @position = Position.new

    respond_to do |format|
      format.html 
      format.xml  { render :xml => @position }
    end
  end

  def edit
    @position = Position.find(params[:id])
  end

  def create
    @position = Position.new(params[:position])

    respond_to do |format|
      if @position.save
        flash[:notice] = 'Position was successfully created.'
        format.html { redirect_to(@position) }
        format.xml  { render :xml => @position, :status => :created, :location => @position }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @position.errors, :status => :unprocessable_entity }
      end
    end
  end

  def update
    @position = Position.find(params[:id])

    respond_to do |format|
      if @position.update_attributes(params[:position])
        flash[:notice] = 'Position was successfully updated.'
        format.html { redirect_to(@position) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @position.errors, :status => :unprocessable_entity }
      end
    end
  end

  def destroy
    @position = Position.find(params[:id])
    @position.destroy

    respond_to do |format|
      format.html { redirect_to(positions_url) }
      format.xml  { head :ok }
    end
  end
end
